package JUnitTest;

import static org.junit.Assert.*;

import org.junit.Test;

import core.dal.OperatorFunctionality;
import core.dto.Database;
import core.dto.IOperatorDTO;
import core.dto.OperatorDTO;
import exceptions.UserNotFoundException;

public class testOperatorFunctionality {

	private Database db;
	private OperatorDTO user1;
	private String oldPass;
	OperatorFunctionality Password;
	
	@org.junit.Before
	public void Before(){
		user1 = new OperatorDTO();
		user1.setCpr("2806934444");
		user1.setOprId(33);
		user1.setOprNavn("Per Larsen");
		user1.setPassword("1234");
		oldPass = user1.getPassword();
		db = new Database();
		
		db.add(user1);
	}

	@Test
	public void testGetUser() throws UserNotFoundException{
			assertEquals(user1, db.getUser(33));
	}
	
	@Test
	public void testChangePassword() throws UserNotFoundException{
		Password = new OperatorFunctionality(db);
		Password.changePassword(33, "9999");
		
			assertNotEquals(user1.getPassword(), oldPass);
	}
	
	
}
